﻿using System;
using System.Collections.Generic;
using System.Text;
using HttpProc;
using GroupChat2013.Common;
using System.Net;
using System.Runtime.Serialization;
using System.Runtime.Remoting.Messaging;
using GroupChat2013.Entity;

namespace GroupChat2013.Service
{
    /// <summary>
    /// 服务调用代理类，用于调用服务API
    /// </summary>
    public class ServiceUrlProxy
    {
        public string m_BaseUrl { get; private set; }

        private static ServiceUrlProxy m_ServiceUrlProxy;
        private static object locker = new object();

        private ServiceUrlProxy()
        {

        }

        /// <summary>
        /// 获取实例
        /// </summary>
        /// <returns></returns>
        public static ServiceUrlProxy GetInstance()
        {
            if (m_ServiceUrlProxy == null)
            {
                lock (locker)
                {
                    if (m_ServiceUrlProxy == null)
                    {
                        lock (locker)
                        {
                            m_ServiceUrlProxy = new ServiceUrlProxy();
                        }
                    }
                }
            }
            return m_ServiceUrlProxy;
        }

        public void SetBaseUrl(string serverIP, string port)
        {
            m_BaseUrl = string.Format("{0}:{1}", serverIP, port);
        }

        /// <summary>
        /// 我的空间
        /// </summary>
        public string MyZOOMURL(string name, string cid)
        {
            return string.Format(ServiceURL.MyZOOMURL, m_BaseUrl, cid);
        }

        /// <summary>
        /// 群空间
        /// </summary>
        public string GroupZOOMURL(string name, string cid, string groupId)
        {
            return string.Format(ServiceURL.GroupZOOMURL, m_BaseUrl, groupId, cid);
        }

        /// <summary>
        /// 文件共享
        /// </summary>
        public string GroupFileShareURL(string name, string cid, string groupId)
        {
            return string.Format(ServiceURL.GroupFileShareURL, m_BaseUrl, groupId, cid);
        }

        /// <summary>
        /// 群聊天信息
        /// </summary>
        public string GroupChatMsgURL(string name, string cid, string groupId)
        {
            return string.Format(ServiceURL.GroupChatMsgURL, m_BaseUrl, groupId, cid);
        }

        /// <summary>
        /// 私聊聊天信息
        /// </summary>
        public string UserChatMsgURL(string name, string cid, string userId)
        {
            return string.Format(ServiceURL.UserChatMsgUrl, m_BaseUrl, userId, cid);
        }

        /// <summary>
        /// 获得自定义表情文件列表的URL
        /// </summary>
        public string UserMeoticonURL()
        {
            return string.Format(ServiceURL.UserMeoticonURL, m_BaseUrl);
        }

        /// <summary>
        /// 上传群聊文件URL
        /// </summary>
        /// <returns></returns>
        public string UploadGroupFileURL(string groupId)
        {
            return string.Format(ServiceURL.UploadGroupFileURL, m_BaseUrl, groupId);
        }

        /// <summary>
        /// 上传群聊天内容中的图片
        /// </summary>
        /// <returns></returns>
        public string UploadGroupChatImageURL(string groupId, string filePath, string cid)
        {
            string url = string.Format(ServiceURL.GroupChatMsgImageUrl, m_BaseUrl, groupId);
            return UpdateMessageImage(url, "", filePath, cid);
        }

        /// <summary>
        /// 上传私聊文件URL
        /// </summary>
        /// <param name="userId"></param>
        /// <returns></returns>
        public string UploadUserFileURL(string receiverId)
        {
            return string.Format(ServiceURL.UploadUserFileURL, m_BaseUrl, receiverId);
        }

        /// <summary>
        /// 上传私群聊天内容中的图片
        /// </summary>
        /// <returns></returns>
        public string UploadUserChatImageURL(string userId, string filePath, string cid)
        {
            string url = string.Format(ServiceURL.UserChatMsgImageUrl, m_BaseUrl, userId);
            return UpdateMessageImage(url, "", filePath, cid);
        }

        /// <summary>
        /// 用户登陆
        /// </summary>
        /// <param name="userName"></param>
        /// <param name="sign"></param>
        /// <returns></returns>
        public LoginValueInfo UserLogin(string rootdeptId, string userName, string password)
        {
            string url = string.Format(ServiceURL.UserLoginURL, m_BaseUrl);
            string value = GroupChat2013.Common.WebClient.PostHttpData(url, string.Format("rootdeptId={0}&loginName={1}&password={2}", rootdeptId, userName, password));

            if (string.IsNullOrEmpty(value))
                return null;

            LoginValueInfo cid = JsonConvert.Parse<LoginValueInfo>(value);
            return cid;
        }

        /// <summary>
        /// 从RTX登陆
        /// </summary>
        /// <param name="userName"></param>
        /// <param name="password"></param>
        /// <returns></returns>
        public LoginValueInfo UserRtxSign(string rootdeptId, string userName, string sign)
        {
            string url = string.Format(ServiceURL.UserSignURL, m_BaseUrl);
            string value = GroupChat2013.Common.WebClient.PostHttpData(url, string.Format("rootdeptId={0}&loginName={1}&sign={2}", rootdeptId, userName, sign));

            if (string.IsNullOrEmpty(value))
                return null;

            LoginValueInfo cid = JsonConvert.Parse<LoginValueInfo>(value);
            return cid;
        }

        /// <summary>
        /// 修改用户信息
        /// </summary>
        /// <param name="userName"></param>
        /// <param name="password"></param>
        /// <returns></returns>
        public bool UpdateUserInfo(string userId, string password, string cid)
        {
            string url = string.Format(ServiceURL.UpdateUserInfo, m_BaseUrl);
            string value = GroupChat2013.Common.WebClient.PostHttpData(url, string.Format("userId={2}&cid={0}&password={1}", cid, password, userId));
            return true;
        }

        /// <summary>
        /// 用户注册
        /// </summary>
        /// <param name="userName"></param>
        /// <param name="password"></param>
        /// <returns></returns>
        //public CIDValue UserRegister(string userName, string password)
        //{
        //    string url = string.Format(ServiceURL.UserRegisterURL, m_BaseUrl);
        //    string value = GroupChat2013.Common.WebClient.PostHttpData(url, string.Format("uname={0}&upass={1}", userName, password));
        //    CIDValue cid = JsonConvert.Parse<CIDValue>(value);
        //    //return cid != null ? cid.obj.cid : string.Empty;
        //    return cid;
        //}

        /// <summary>
        /// 用户注销
        /// </summary>
        /// <param name="cid"></param>
        //public void UserUnRegister(string cid)
        //{
        //    if (string.IsNullOrEmpty(cid))
        //        return;

        //    CookieContainer cookie = new CookieContainer();
        //    cookie.Add(new System.Uri("http://" + m_BaseUrl), new Cookie("cid", cid));

        //    string url = string.Format(ServiceURL.UserUnRegisterURL, m_BaseUrl);
        //    GroupChat2013.Common.WebClient.GetHttpData(url, cookie);
        //}

        /// <summary>
        /// 上传用户自定义表情
        /// </summary>
        /// <param name="fileField"></param>
        /// <param name="cookie"></param>
        /// <returns></returns>
        public string UpdateUserMeoticon(string filePath, string cookie)
        {
            HttpProc.WebClient webClient = new HttpProc.WebClient();
            webClient.Encoding = System.Text.Encoding.Default;//默认编码方式，根据需要设置其他类型

            string url = string.Format(ServiceURL.UpdateUserMeoticonURL, m_BaseUrl);
            return webClient.UploadFileWithCookie(url, string.Format(@"file={0}", filePath), cookie);
            //return webClient.UploadFile(url, "cid=" + cookie, fileField);
        }

        /// <summary>
        /// 获取群聊天信息
        /// </summary>
        /// <param name="groupId"></param>
        /// <param name="cid"></param>
        /// <returns></returns>
        public List<MessageInfo> GetGroupMessage(string groupId, string cid)
        {
            try
            {
                string url = string.Format(ServiceURL.GroupMessageURL, m_BaseUrl, groupId);
                CookieContainer cookie = new CookieContainer();
                cookie.Add(new System.Uri("http://" + m_BaseUrl), new Cookie("cid", cid));

                string value = GroupChat2013.Common.WebClient.GetHttpData(url, cookie);

                return JsonConvert.Parse<List<MessageInfo>>(value);
            }
            catch { return new List<MessageInfo>(); }
        }

        /// <summary>
        /// 发送群聊信息
        /// </summary>
        /// <param name="groupId"></param>
        /// <param name="?"></param>
        /// <param name="?"></param>
        /// <param name="cid"></param>
        /// <returns></returns>
        public List<MessageInfo> SendGroupMessage(string groupId, string content, string cid)
        {
            try
            {
                string url = string.Format(ServiceURL.GroupMessageURL, m_BaseUrl, groupId);
                CookieContainer cookie = new CookieContainer();
                cookie.Add(new System.Uri("http://" + m_BaseUrl), new Cookie("cid", cid));

                string value = GroupChat2013.Common.WebClient.PostHttpData(url, "content=" + content, cookie);

                return JsonConvert.Parse<List<MessageInfo>>(value);
            }
            catch { return new List<MessageInfo>(); }
        }

        /// <summary>
        /// 接受用户私聊信息
        /// </summary>
        /// <param name="userId"></param>
        /// <param name="cid"></param>
        /// <returns></returns>
        public List<MessageInfo> GetUserMessage(string userId, string cid)
        {
            try
            {
                string url = string.Format(ServiceURL.UserMessageURL, m_BaseUrl, userId);
                CookieContainer cookie = new CookieContainer();
                cookie.Add(new System.Uri("http://" + m_BaseUrl), new Cookie("cid", cid));

                string value = GroupChat2013.Common.WebClient.GetHttpData(url, cookie);

                return JsonConvert.Parse<List<MessageInfo>>(value);
            }
            catch { return new List<MessageInfo>(); }
        }

        /// <summary>
        /// 发送用户私聊信息
        /// </summary>
        /// <param name="userId"></param>
        /// <param name="content"></param>
        /// <param name="cid"></param>
        /// <returns></returns>
        public List<MessageInfo> SendUserMessage(string userId, string content, string cid)
        {
            try
            {
                string url = string.Format(ServiceURL.UserMessageURL, m_BaseUrl, userId);
                CookieContainer cookie = new CookieContainer();
                cookie.Add(new System.Uri("http://" + m_BaseUrl), new Cookie("cid", cid));

                string value = GroupChat2013.Common.WebClient.PostHttpData(url, "content=" + content, cookie);

                return JsonConvert.Parse<List<MessageInfo>>(value);
            }
            catch { return new List<MessageInfo>(); }
        }

        /// <summary>
        /// 获取群用户列表
        /// </summary>
        /// <param name="groupId"></param>
        /// <param name="cid"></param>
        public List<FriendInfo> GetGroupUserList(string groupId, string cid)
        {
            try
            {
                string url = string.Format(ServiceURL.GetGroupUserListURL, m_BaseUrl, groupId);
                CookieContainer cookie = new CookieContainer();
                cookie.Add(new System.Uri("http://" + m_BaseUrl), new Cookie("cid", cid));

                string value = GroupChat2013.Common.WebClient.GetHttpData(url, cookie);

                return JsonConvert.Parse<List<FriendInfo>>(value);
            }
            catch { return new List<FriendInfo>(); }
        }

        /// <summary>
        /// 获取公告
        /// </summary>
        /// <param name="groupId"></param>
        /// <param name="cid"></param>
        /// <param name="startIndex"></param>
        /// <param name="count"></param>
        /// <returns></returns>
        public List<Notice> GetGroupNotice(string groupId, string cid, int startIndex, int count)
        {
            try
            {
                string url = string.Format(ServiceURL.GetGroupNotice, m_BaseUrl, groupId, startIndex, count);
                CookieContainer cookie = new CookieContainer();
                cookie.Add(new System.Uri("http://" + m_BaseUrl), new Cookie("cid", cid));

                string value = GroupChat2013.Common.WebClient.GetHttpData(url, cookie);

                return JsonConvert.Parse<List<Notice>>(value);
            }
            catch { return null; }
        }

        /// <summary>
        /// 上传聊天信息中的本地图片
        /// </summary>
        /// <param name="filePath"></param>
        /// <param name="cid"></param>
        private string UpdateMessageImage(string url, string textField, string filePath, string cid)
        {
            try
            {
                HttpProc.WebClient webClient = new HttpProc.WebClient();
                webClient.Encoding = System.Text.Encoding.Default;//默认编码方式，根据需要设置其他类型

                return webClient.UploadImageWithCookie(url, textField, string.Format(@"file={0}", filePath), "cid=" + cid);
            }
            catch { return string.Empty; }
        }

        /// <summary>
        /// 获取群明细
        /// </summary>
        /// <param name="groupId"></param>
        /// <param name="cid"></param>
        /// <returns></returns>
        public GroupInfo GetGroupInfo(string groupId, string cid)
        {
            try
            {
                string url = string.Format(ServiceURL.GroupInfoURL, m_BaseUrl, groupId);
                CookieContainer cookie = new CookieContainer();
                cookie.Add(new System.Uri("http://" + m_BaseUrl), new Cookie("cid", cid));

                string value = GroupChat2013.Common.WebClient.GetHttpData(url, cookie);

                return JsonConvert.Parse<GroupInfo>(value);
            }
            catch { return null; }
        }

        /// <summary>
        /// 获取群列表
        /// </summary>
        /// <param name="cid"></param>
        /// <returns></returns>
        public List<GroupInfo> GetGroupList(string cid)
        {
            try
            {
                string url = string.Format(ServiceURL.GroupListURL, m_BaseUrl);
                CookieContainer cookie = new CookieContainer();
                cookie.Add(new System.Uri("http://" + m_BaseUrl), new Cookie("cid", cid));

                string value = GroupChat2013.Common.WebClient.GetHttpData(url, cookie);
                return JsonConvert.Parse<List<GroupInfo>>(value);
            }
            catch { return null; }
        }

        /// <summary>
        /// 异步获取群信息
        /// </summary>
        /// <param name="groupId"></param>
        /// <param name="cid"></param>
        /// <param name="action"></param>
        public void AsyncGetGroupInfo(string groupId, string cid, Action<GroupInfo> action)
        {
            Func<GroupInfo> func = () =>
            {
                return m_ServiceUrlProxy.GetGroupInfo(groupId, cid);
            };

            func.BeginInvoke((a) =>
            {
                Func<GroupInfo> f = a.AsyncState as Func<GroupInfo>;
                GroupInfo groupInfo = f();
                action(groupInfo);
            }, func);
        }

        /// <summary>
        /// 读取私聊图片文件
        /// </summary>
        /// <param name="fromUserId"></param>
        /// <param name="toUserId"></param>
        /// <param name="imageMD5Name"></param>
        public void DownUserChatImage(string cid, string fromUserId, string toUserId, string imageMD5Name, string savePath)
        {
            try
            {
                //HttpProc.WebClient webClient = new HttpProc.WebClient();
                //webClient.Encoding = System.Text.Encoding.Default;//默认编码方式，根据需要设置其他类型
                string url = string.Format(ServiceURL.UserChatImageURL, m_BaseUrl, fromUserId, toUserId, imageMD5Name, cid);
                //webClient.DownloadFile(url, savePath);
                FileManage.SaveFileForUrl(url, savePath);
            }
            catch { }
        }

        /// <summary>
        /// 读取群聊图片文件
        /// </summary>
        /// <param name="fromUserId"></param>
        /// <param name="toUserId"></param>
        /// <param name="imageMD5Name"></param>
        public void DownGroupChatImage(string cid, string groupId, string imageMD5Name, string savePath)
        {
            try
            {
                //HttpProc.WebClient webClient = new HttpProc.WebClient();
                //webClient.Encoding = System.Text.Encoding.Default;//默认编码方式，根据需要设置其他类型
                string url = string.Format(ServiceURL.GroupChatImageURL, m_BaseUrl, groupId, imageMD5Name, cid);
                // webClient.DownloadFile(url, savePath);
                FileManage.SaveFileForUrl(url, savePath);
            }
            catch { }
        }

        /// <summary>
        /// 获取组织架构的根节点
        /// </summary>
        /// <param name="cid"></param>
        /// <returns></returns>
        public OrganizeInfo GetOrganizeRootNode(string cid)
        {
            try
            {
                string url = string.Format(ServiceURL.OrganizeRootNode, m_BaseUrl, cid);
                string value = GroupChat2013.Common.WebClient.GetHttpData(url);
                return JsonConvert.Parse<OrganizeInfo>(value);
            }
            catch { return new OrganizeInfo(); }
        }

        /// <summary>
        /// 获取组织架构的根节点
        /// </summary>
        /// <param name="cid"></param>
        /// <returns></returns>
        public OrganizeInfo GetOrganizeChildNode(string partUrl, out bool error)
        {
            try
            {
                error = false;
                string url = string.Format(ServiceURL.OrganizeChatNode, m_BaseUrl, partUrl);
                string value = GroupChat2013.Common.WebClient.GetHttpData(url);
                return JsonConvert.Parse<OrganizeInfo>(value);
            }
            catch { error = true; return null; }
        }

        /// <summary>
        /// 获取个人分享通知内容
        /// </summary>
        /// <param name="userId"></param>
        /// <returns></returns>
        public PersonShareInfo GetPersonShareFile(string shareFromUserId, string storeFileName, string cid)
        {
            try
            {
                string url = string.Format(ServiceURL.GetPersonShareFileUrl, m_BaseUrl, shareFromUserId, storeFileName, cid);
                string value = GroupChat2013.Common.WebClient.GetHttpData(url);
                return JsonConvert.Parse<PersonShareInfo>(value);
            }
            catch { return null; }
        }

        /// <summary>
        /// 获取群分享通知内容
        /// </summary>
        /// <returns></returns>
        public GroupShareInfo GetGroupShareFile(string shareFromGroupId, string storeFileName, string cid)
        {
            try
            {
                string url = string.Format(ServiceURL.GetGroupShareFileUrl, m_BaseUrl, shareFromGroupId, storeFileName, cid);
                string value = GroupChat2013.Common.WebClient.GetHttpData(url);
                return JsonConvert.Parse<GroupShareInfo>(value);
            }
            catch { return null; }
        }

        /// <summary>
        /// 主面板Tab页签配置
        /// </summary>
        /// <returns></returns>
        public TabConfigInfo GetTabConfig()
        {
            try
            {
                string url = string.Format(ServiceURL.TabConfigURL, m_BaseUrl);
                string value = GroupChat2013.Common.WebClient.GetHttpData(url);
                return JsonConvert.Parse<TabConfigInfo>(value);
            }
            catch { return null; }
        }

        /// <summary>
        /// 主面板按钮配置
        /// </summary>
        /// <returns></returns>
        public Dictionary<string, ButtonConfigInfo> GetMainButtonConfig()
        {
            try
            {
                string url = string.Format(ServiceURL.MainButtonConfigURL, m_BaseUrl);
                string value = GroupChat2013.Common.WebClient.GetHttpData(url);
                return JsonConvert.Parse<Dictionary<string, ButtonConfigInfo>>(value);
            }
            catch { return null; }
        }

        /// <summary>
        /// 应用按钮区域配置
        /// </summary>
        /// <returns></returns>
        public Dictionary<string, ButtonConfigInfo> GetPersonAppConfig()
        {
            try
            {
                string url = string.Format(ServiceURL.PersonAppConfig, m_BaseUrl);
                string value = GroupChat2013.Common.WebClient.GetHttpData(url);
                return JsonConvert.Parse<Dictionary<string, ButtonConfigInfo>>(value);
            }
            catch { return null; }
        }

        /// <summary>
        /// 群聊窗口按钮配置信息
        /// </summary>
        /// <returns></returns>
        public Dictionary<string, ButtonConfigInfo> GetGroupAppConfig()
        {
            try
            {
                string url = string.Format(ServiceURL.GroupAppConfig, m_BaseUrl);
                string value = GroupChat2013.Common.WebClient.GetHttpData(url);
                return JsonConvert.Parse<Dictionary<string, ButtonConfigInfo>>(value);
            }
            catch { return null; }
        }

        /// <summary>
        /// 通知栏
        /// </summary>
        /// <returns></returns>
        public AnnounceConfigInfo GetAnnounceConfig()
        {
            try
            {
                string url = string.Format(ServiceURL.AnnounceConfig, m_BaseUrl);
                string value = GroupChat2013.Common.WebClient.GetHttpData(url);
                return JsonConvert.Parse<AnnounceConfigInfo>(value);
            }
            catch { return null; }
        }

        /// <summary>
        /// 分页获取私聊天记录
        /// </summary>
        /// <param name="userId"></param>
        /// <param name="cid"></param>
        /// <returns></returns>
        public ChatRecordInfo GetUserMessage(string userId, int startIndex, int count, string cid)
        {
            try
            {
                string url = string.Format(ServiceURL.UserChatMsgRecordUrl, m_BaseUrl, userId, startIndex, count);
                CookieContainer cookie = new CookieContainer();
                cookie.Add(new System.Uri("http://" + m_BaseUrl), new Cookie("cid", cid));

                string value = GroupChat2013.Common.WebClient.GetHttpData(url, cookie);

                return JsonConvert.Parse<ChatRecordInfo>(value);
            }
            catch { return new ChatRecordInfo(); }
        }

        /// <summary>
        /// 分页获取群聊天记录
        /// </summary>
        /// <param name="groupId"></param>
        /// <param name="cid"></param>
        /// <returns></returns>
        public ChatRecordInfo GetGroupChatMsgRecord(string groupId, int startIndex, int count, string cid)
        {
            try
            {
                string url = string.Format(ServiceURL.GroupChatMsgRecordUrl, m_BaseUrl, groupId, startIndex, count);
                CookieContainer cookie = new CookieContainer();
                cookie.Add(new System.Uri("http://" + m_BaseUrl), new Cookie("cid", cid));

                string value = GroupChat2013.Common.WebClient.GetHttpData(url, cookie);

                return JsonConvert.Parse<ChatRecordInfo>(value);
            }
            catch { return new ChatRecordInfo(); }
        }

        #region 群管理

        /// <summary>
        /// 获取群列表
        /// </summary>
        /// <param name="cid"></param>
        /// <returns></returns>
        public List<GroupInfo> GetManageGroupList(string cid)
        {
            try
            {
                string url = string.Format(ServiceURL.GetManageGroupListUrl, m_BaseUrl, cid);

                string value = GroupChat2013.Common.WebClient.GetHttpData(url);
                return JsonConvert.Parse<List<GroupInfo>>(value);
            }
            catch { return null; }
        }

        /// <summary>
        /// 创建群
        /// </summary>
        /// <param name="cid"></param>
        /// <returns></returns>
        public GroupInfo AddGroup(string groupName, string cid)
        {
            try
            {
                string url = string.Format(ServiceURL.AddGroupUrl, m_BaseUrl, cid, groupName);

                string value = GroupChat2013.Common.WebClient.PostHttpData(url);
                return JsonConvert.Parse<GroupInfo>(value);
            }
            catch { return null; }
        }

        /// <summary>
        /// 修改群
        /// </summary>
        /// <param name="cid"></param>
        /// <returns></returns>
        public GroupInfo UpdateGroup(string groupId, string groupName, string cid)
        {
            try
            {
                string url = string.Format(ServiceURL.UpdateGroupUrl, m_BaseUrl, groupId, cid, groupName);

                string value = GroupChat2013.Common.WebClient.PostHttpData(url);
                return JsonConvert.Parse<GroupInfo>(value);
            }
            catch { return null; }
        }

        /// <summary>
        /// 删除群
        /// </summary>
        /// <param name="cid"></param>
        /// <returns></returns>
        public bool DeleteGroup(string groupId, string cid)
        {
            try
            {
                string url = string.Format(ServiceURL.DeleteGroupUrl, m_BaseUrl, groupId, cid);

                string value = GroupChat2013.Common.WebClient.DeleteHttpData(url,string.Empty);
                return value.Contains("true");
            }
            catch { return false; }
        }

        /// <summary>
        /// 修改群公告
        /// </summary>
        /// <param name="cid"></param>
        /// <returns></returns>
        public bool SetGroupNotice(string groupId, string cid, string groupNotice)
        {
            try
            {
                string url = string.Format(ServiceURL.SetGroupNoticeUrl, m_BaseUrl, groupId, cid, groupNotice);

                string value = GroupChat2013.Common.WebClient.PostHttpData(url);
                return value.Contains("true");
            }
            catch { return false; }
        }

        /// <summary>
        /// 添加群用户
        /// </summary>
        /// <param name="cid"></param>
        /// <returns></returns>
        public bool AddGroupUser(string groupId, string cid, string userids)
        {
            try
            {
                string url = string.Format(ServiceURL.AddGroupUserUrl, m_BaseUrl, groupId, cid, userids);

                string value = GroupChat2013.Common.WebClient.PostHttpData(url);
                return value.Contains("true");
            }
            catch { return false; }
        }

        #endregion
    }
}
